//
//  JMBCouponAddSelectCell.m
//  SYPerfectDemo
//
//  Created by Lssyyy on 2019/8/8.
//  Copyright © 2019年 Lssyyy. All rights reserved.
//

#import "JMBCouponAddSelectCell.h"

@implementation JMBCouponAddSelectCell

- (void)addUI{
    self.topSepView.sd_layout
    .leftEqualToView(self.contentView)
    .rightEqualToView(self.contentView)
    .heightIs(10)
    .topEqualToView(self.contentView);
    
    self.titleLabel.sd_layout
    .leftSpaceToView(self.contentView, 15)
    .topSpaceToView(_topSepView, 0)
    .heightIs(50);
    [self.titleLabel setSingleLineAutoResizeWithMaxWidth:0.4 *UI_SCREEN_WIDTH];
    
    self.detailLabel.sd_layout
    .leftSpaceToView(self.titleLabel, 10)
    .rightSpaceToView(self.contentView,15)
    .heightIs(50)
    .centerYEqualToView(self.titleLabel);
}

- (void)setItem:(CouponFormItem *)item{
    _item = item;
    self.titleLabel.attributedText = item.attributedTitle;
    if (!kStringIsEmpty(item.info)) {
        _detailLabel.text = item.info;
        _detailLabel.textColor = UIColorHex(333333);
    }else{
         _detailLabel.text = item.placeholder;
         _detailLabel.textColor = UIColorHex(B2B2B2);
    }
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:14];
        _titleLabel.textColor = UIColorHex(333333);
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (UILabel *)detailLabel {
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc]init];
        _detailLabel.font = [UIFont systemFontOfSize:14];
        _detailLabel.textColor = UIColorHex(B2B2B2);
        _detailLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_detailLabel];
    }
    return _detailLabel;
}

- (UIView *)topSepView{
    if (!_topSepView) {
        _topSepView = [UIView new];
        _topSepView.backgroundColor = UIColorHex(F3F3F3);
        [self.contentView addSubview:_topSepView];
    }
    return _topSepView;
}
@end
